from django.contrib import admin
from django.urls import path,include
from .serializers import StudentSerializers
from .views import StudentViewSet,ClassesViewSet

from rest_framework.routers import DefaultRouter

#    127.0.0.1:8000/drfstudy/students
urlpatterns = [
        # path("students/",StudentViewSet.as_view({"get":"list","post":"create"})),
        #
        # path("students/<pk>/",StudentViewSet.as_view({"get":"retrieve","put":"update","delete":"destroy"}))
]

router = DefaultRouter()   #  实例化  得到路由器对象
#  注册路由
router.register("students",StudentViewSet)
router.register("classes",ClassesViewSet)
#  拼接路由
urlpatterns += router.urls